from django.db import models

# Create your models here.
from article.models import Article
from bloguser.models import UserProfile


class Comment(models.Model):
    article = models.ForeignKey(Article, on_delete=models.CASCADE, verbose_name='被评论文章')
    user = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
    com_body = models.TextField()
    created_time = models.DateTimeField(auto_now_add=True, verbose_name='评论时间')

    class Meta:
        db_table = 'Comment'
        verbose_name = '博客评论'
        verbose_name_plural = verbose_name
        ordering = ('-created_time',)

    def __str__(self):
        return self.com_body[:20]
